import { Logger } from "./Logger"
import { Config } from "../../config/Config";
import { EventManager } from "./EventManager";
import DateUtil from "./DateUtil";
import { AccountModel } from "../../../account_server/model/AccountModel";
import { LogClearManager } from "../../../log_server/LogClearManager";
import { ServerConfig } from "../../config/ServerConfig";
import { hall_server_TimerManager } from "../../../hall_server/hall_server_TimerManager";
import { TimerManager } from "../../server/TimerManager";
import { LogAddManager } from "../../../log_server/LogAddManager";
import { LogTest } from "../../../log_server/LogTest";

export class TimerUtil {

    public static init() {
        setInterval(() => {
            try {
                let now: number = DateUtil.now();
                if (ServerConfig.nowServerConfig) {
                    TimerManager.instance.checkTimer(now)
                    if (Config.serverType == Config.ServerType_List.log_server) {
                        LogTest.instance.checkJoinServer(now)
                        LogClearManager.instance.checkClear(now)
                        LogAddManager.instance.checkDayLog(now)
                    }
                    else if (Config.serverType == Config.ServerType_List.hall_server) {
                        hall_server_TimerManager.instance.checkTimer(now);
                    }
                    // else if (Config.serverType == Config.ServerType_List.huanghua_mj_server) {
                    //     huanghua_mj_TimerManager.instance.checkTimer(now)
                    // }
                    // else if (Config.serverType == Config.ServerType_List.ddz_server) {
                    //     ddz_TimerManager.instance.checkTimer(now);
                    // }
                    // else if (Config.serverType == Config.ServerType_List.jianziding_server) {
                    //     jianziding_TimerManager.instance.checkTimer(now);
                    // }
                    // else if (Config.serverType == Config.ServerType_List.cangxian_mj_server) {
                    //     cangxian_TimerManager.instance.checkTimer(now);
                    // }
                    // else if (Config.serverType == Config.ServerType_List.paodekuai_server) {
                    //     paodekuai_TimerManager.instance.checkTimer(now)
                    // }
                    // else if (Config.serverType == Config.ServerType_List.dazhonger_mj_server) {
                    //     dazhonger_mj_TimerManager.instance.checkTimer(now)
                    // }
                }
                EventManager.instance.dispatch(Config.Event_Config.Timer, now)
            } catch (error) {
                Logger.error("TimerUtil.error=-=", error)
            }
        }, 50)
    }
}